package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.HospitalService;
import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.sql.ResultSet;
import java.util.Map;

/**
 * @FileName: HospitalController
 * @Author Steven
 * @Date: 2021/3/22
 */
@Api(tags = "医院管理接口")
@RequestMapping("/admin/hosp/hospital")
@RestController
public class HospitalController {

    @Autowired
    HospitalService hospitalService;

    @ApiOperation("分页查询医院信息")
    @GetMapping("list/{current}/{limit}")
    public Result hospList(
             @PathVariable("current") Integer current,
             @PathVariable("limit")  Integer limit,
             HospitalQueryVo hospitalQueryVo){
        Page<Hospital> hospitals = hospitalService.selectPage(current, limit, hospitalQueryVo);
        return Result.ok(hospitals);
    }

    @ApiOperation("更新线上状态")
    @GetMapping("lock/{id}/{status}")
    public Result lock(@PathVariable String id,
                       @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return Result.ok();
    }

    @ApiOperation("查看医院详细信息")
    @GetMapping("/show/{id}")
    public Result show(@PathVariable  String id){
        Map<String, Object> show = hospitalService.show(id);
        return Result.ok(show);
    }
}
